/*
 * Copyright 2008 Mark Davidson.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package org.doofer.test

import groovy.util.*

/**
 * Base class for Doofer tests.
 */
class DooferBaseTest extends GroovyTestCase {

    static final def PROP_USERNAME = 'username'         // property key for username
    static final def PROP_PASSWORD = 'password'         // property key for password
    static final def PROP_REPOSITORY = 'repository'     // property key for repository
    static final def PROP_IMPERSONATED = 'impersonated' // property key for impersonated user

    final def properties = new Properties()
    static final def DEFAULT_CONFIG_FILE = '/doofer-test.properties'
    def configFile = DEFAULT_CONFIG_FILE

    def username        // the username
    def password        // the password
    def repository      // the repository name
    def impersonated    // the username to impersonate

    void setUp() {
        super.setUp()
        def input = this.class.getResourceAsStream(configFile)
        if(input) {
            properties.load(input)

            username = properties?.getProperty(PROP_USERNAME)
            password = properties?.getProperty(PROP_PASSWORD)
            repository = properties?.getProperty(PROP_REPOSITORY)
            impersonated = properties?.getProperty(PROP_IMPERSONATED)
        } else {
            throw new Exception("Cannot find properties file $configFile")
        }
    }

    void testDummy() {
        assert(true)
    }

    /*
    void testProperties() {
        assert(username)
        assert(password)
        assert(repository)
        assert(impersonated)
    }
    */
}